var t = getApp();

Component({
    properties: {
        attention: {
            type: Number,
            value: 0
        },
        userAccessToken: {
            type: String,
            value: ""
        }
    },
    data: {},
    methods: {
        bindAttentionTap: function() {
            if (t.util.isLoginModal()) {
                var a = this;
                1 == a.data.attention ? t.network.post({
                    url: t.url.cancelAttention,
                    params: {
                        attentionAccessToken: a.data.userAccessToken
                    },
                    before: function() {
                        a.setData({
                            attention: 0
                        });
                    },
                    success: function(e) {
                        1 == e.data.result ? t.util.showToast("取消关注成功") : (t.util.showToast(e.data.message), 
                        a.setData({
                            attention: 1
                        }));
                    },
                    fail: function() {
                        t.util.showToast("取消关注失败");
                        a.data.zanCount;
                        a.setData({
                            attention: 1
                        });
                    },
                    complete: function() {}
                }) : t.network.post({
                    url: t.url.attentionUser,
                    params: {
                        attentionAccessToken: a.data.userAccessToken
                    },
                    before: function() {
                        a.setData({
                            attention: 1
                        });
                    },
                    success: function(e) {
                        1 == e.data.result ? t.util.showToast("关注成功") : (t.util.showToast(e.data.message), 
                        a.setData({
                            attention: 0
                        }));
                    },
                    fail: function() {
                        t.util.showToast("关注失败"), a.setData({
                            attention: 0
                        });
                    },
                    complete: function() {}
                });
            }
        }
    }
});